//
//  KAliasViewController.m
//  Keping
//
//  Created by 柯平 on 2017/9/11.
//  Copyright © 2017年 柯平. All rights reserved.
//

#import "KAliasViewController.h"
#import "KPureInputTextCell.h"
#import "GPContactRequest.h"

@interface KAliasViewController ()
{
    NSString* _placeholder;
    NSString* _originText;
    NSInteger _mode;
    
}

@property(nonatomic,copy)NSString* text;

@end

@implementation KAliasViewController

-(instancetype)initWithPlaceholder:(NSString *)placeholder originText:(NSString *)originText inputMode:(NSInteger)mode
{
    self = [super init];
    if (self) {
        _placeholder = placeholder;
        _originText = originText;
        _mode = mode;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"Alias";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction)];
    
    
}

-(void)saveAction
{
    
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return [NSString stringWithFormat:@"\t%@",_originText];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    @weakify(self);
    KPureInputTextCell* cell = [tableView dequeueReusableCellWithIdentifier:[KPureInputTextCell className]];
    if (!cell) {
        cell = [[KPureInputTextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[KPureInputTextCell className]];
    }
    cell.txfield.placeholder = _placeholder;
    cell.txfield.text = _originText;
    
    cell.textBlock = ^(NSString *text) {
        if ([text isNotBlank]) {
            weak_self.text = text;
        }
    };
    return cell;
}



@end
